<style>
.layui-input-block{
margin-top:10px;
margin-left:120px;
}
</style>
<form class="layui-form" action="" id="orderEditForm">
	 <input type="hidden" name="id" th:value="${id}">
	  <div class="layui-form-item">
		    <label class="layui-form-label" style="width:120px;">旧密码</label>
		    <div class="layui-input-block" style="width:200px;">
		        <input type="password" class="layui-input"  name="opd" lay-verify="required" />
		    </div>
	   </div>
	  <div class="layui-form-item">
		    <label class="layui-form-label" style="width:120px;">新密码</label>
		    <div class="layui-input-block" style="width:200px;">
		        <input type="password" class="layui-input"  name="npd" lay-verify="required" />
		    </div>
	   </div>
  

	  <div class="layui-form-item">
		    <label class="layui-form-label" style="width:120px;">再次输入</label>
		    <div class="layui-input-block" style="width:200px;">
		        <input type="password" class="layui-input"  name="npda" lay-verify="required" />
		    </div>
	   </div>
  
  
 <div class="layui-row" style="margin-top:20px;">
    <div class="layui-col-xs12 layui-col-sm12 layui-col-md12" style="text-align:center;">
      	<button type="button" class="layui-btn" lay-submit="" lay-filter="formSubmit" authcode="900259">提交</button>
      	<button type="button" class="layui-btn layui-btn-primary" id="closeBtn">关闭</button>
    </div>
  </div>
</form>
<script>
layui.use('form', function(){
		var form = layui.form;
		form.render();
		
		var submit=false;
		$("[name='npda']").blur(function(){
			if($("[name='npda']").val() == $("[name='npd']").val()){
				submit=true;
			}else{
				layer.msg("两次密码不一致！");
			}
			
		});
		
		form.on('submit(formSubmit)', function(data){
	  		if(!submit){
	  			layer.msg("两次密码不一致！");
	  			return false;
	  		}
	  		 
	  		$.ajax({
	            type: "POST",
	            url: "/act/center/company/pwdSave",
	            data: $("#orderEditForm").serializeJson(),
	            dataType: "json",
	            success: function(data){
	            	if(data.code==200){
	           	    //更新表格数据
	           	    layer.msg(data.message,{icon: 6});
	           		//关闭弹出层
	           	    layer.closeAll();
	            	}else{
	            		layer.msg(data.message,{icon: 2});
	            	}
	            }
	           });
	  	 })
	 
		 //关闭按钮
		  $("#closeBtn").click(function(){
			  layer.closeAll();
		  })
	});  
</script>
